#!/bin/sh
ME=`basename "$0"`
DIR=/home/shared/xmltv_guide
TM1=/tmp/$ME.$USER.tmp
UCACHE="$HOME/.cache"
mkdir -p "$UCACHE" || exit 1
CACHE="$UCACHE/$ME.daylist.txt"
{
 cat "$CACHE"
 ls "$DIR"/day-*.xmltv |
 sed "s~^.*/\([^/]*\)$~\1~" |
 tee "$TM1"
 cat "$TM1"
} |
sort |
uniq -c |
grep "^[^0-9]*2[^0-9]" |
sed "s~^[^0-9]*2[^0-9]~~" |
sed "s~^~$DIR/~" |
xargs --no-run-if-empty ln -svt "$HOME/.freeguide/"
diff "$TM1" "$CACHE" ||
 mv -v "$TM1" "$CACHE"
exec nice freeguide
